<?php
require_once 'common.php';
$method = $_SERVER['REQUEST_METHOD'];
$result = [];
switch($method) {
    case 'POST':
        $params = file_get_contents('php://input');
        $params = json_decode($params, true);
        $res = SQLiteDB::addUser($params);
        $result = [
            'status' => (boolean)$res
        ];
    break;
    case 'DELETE';
        if (isset($_GET['user'])) {
            SQLiteDB::deleteUser($_GET['user']);
        }
    break;
    default:
        $result = SQLiteDB::getUser();
    break;
}

echo json_encode($result);